﻿namespace QLBanHang.UC
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraBars;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Mask;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using Access;
    using Access.Duoc;
    using BaseClass.Duoc;
    using Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using UserControls;

    public class ucd_xuatkho_banle_ll_khonghoadon : XtraUserControl
    {
        private dtoDXuatBanLe _dtobanle;
        private int _iiddangnhap;
        private DXuatBanLe _xuatban;
        private General _xuli;
        private Bar bar1;
        private BarCheckItem barCheckItem1;
        private BarCheckItem barCheckItem2;
        private BarDockControl barDockControlBottom;
        private BarDockControl barDockControlLeft;
        private BarDockControl barDockControlRight;
        private BarDockControl barDockControlTop;
        private BarEditItem barEditItem1;
        private BarEditItem barEditItem2;
        private BarEditItem barEditItem3;
        private BarEditItem barEditItem4;
        private BarEditItem barEditItem5;
        private BarManager barManager1;
        private BarSubItem barSubItem1;
        private BarButtonItem bbiboqua;
        private BarButtonItem bbiinphieu;
        private BarButtonItem bbiketthuc;
        private BarButtonItem bbiluu;
        private BarEditItem bbithuockhongkedon;
        private BarEditItem bbixemtruocin;
        private SimpleButton btnthem;
        private SimpleButton btnxoa;
        private LookUpEdit cbbdonggoi;
        private LookUpEdit cbbnhomkh;
        private IContainer components;
        private ctrdanhsach ctrdanhsach_vp;
        private DateEdit datengay;
        private GridControl gridds;
        private GridColumn gridds_dongia;
        private GridColumn gridds_dvt;
        private GridColumn gridds_giaban;
        private GridColumn gridds_hangsx;
        private GridColumn gridds_id;
        private GridColumn gridds_idnhapct;
        private GridColumn gridds_idvitrikho;
        private GridColumn gridds_ma;
        private GridColumn gridds_ngaysx;
        private GridColumn gridds_slxuat;
        private GridColumn gridds_soluong;
        private GridColumn gridds_ten;
        private GridColumn gridds_tenhoatchat;
        private GridColumn gridds_tenvitrikho;
        private GridColumn gridds_thanhtien;
        private GridColumn gridds_thue;
        private GridColumn gridds_tongtien;
        private GridView gridView1;
        private GroupControl groupControl1;
        private GroupControl groupControl2;
        private Label label1;
        private Label label14;
        private Label label19;
        private Label label2;
        private Label label28;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label8;
        private Label lblmaso;
        private Label lblthuathieu;
        private RepositoryItemCheckEdit repositoryItemCheckEdit1;
        private RepositoryItemCheckEdit repositoryItemCheckEdit2;
        private RepositoryItemCheckEdit repositoryItemCheckEdit3;
        private RepositoryItemCheckEdit repositoryItemCheckEdit4;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private RepositoryItemTextEdit repositoryItemTextEdit2;
        private RepositoryItemTextEdit repositoryItemTextEdit3;
        private RepositoryItemTextEdit repositoryItemTextEdit4;
        private StandaloneBarDockControl standaloneBarDockControl1;
        private TextEdit txtma;
        private TextEdit txtmavach;
        private TextEdit txtsoluong;
        private TextEdit txtsophieu;
        private TextEdit txtten;
        private TextEdit txttongchietkhau;
        private TextEdit txttongthanhtoan;
        private TextEdit txttongthucthu;
        private TextEdit txttongtien;
        private TextEdit txttongtienthua;
        private TextEdit txttongvat;

        public ucd_xuatkho_banle_ll_khonghoadon()
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
            this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
        }

        public ucd_xuatkho_banle_ll_khonghoadon(int iddangnhap)
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
            this._iiddangnhap = iddangnhap;
            this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
        }

        public ucd_xuatkho_banle_ll_khonghoadon(General xuli, int iddangnhap)
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._iiddangnhap = iddangnhap;
            this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
        }

        public ucd_xuatkho_banle_ll_khonghoadon(General xuli, dtoDXuatBanLe dtoxuatban, int iddangnhap)
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._dtobanle = dtoxuatban;
            this._iiddangnhap = iddangnhap;
        }

        private void bbiboqua_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnboqua_Click(null, null);
        }

        private void bbiinphieu_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnin_Click(null, null);
        }

        private void bbiketthuc_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnketthuc_Click(null, null);
        }

        private void bbiluu_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnluu_Click(null, null);
        }

        private void bbithuockhongkedon_ItemClick(object sender, ItemClickEventArgs e)
        {
        }

        private void btnboqua_Click(object sender, EventArgs e)
        {
            if (this.bbiboqua.Visibility != BarItemVisibility.Never)
            {
                this.f_Control_enable(false);
            }
        }

        private void btnhuy_Click(object sender, EventArgs e)
        {
            if (this.txtsophieu.Tag.ToString() != "0")
            {
                dtoDXuatBanLe xuatban = new dtoDXuatBanLe(this._xuli.pConFigData) {
                    pID = long.Parse(this.txtsophieu.Tag.ToString())
                };
                xuatban.Load();
                if (!this._xuatban.f_huy_xuatbanle(xuatban))
                {
                    MessageBox.Show("Hủy kh\x00f4ng th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                }
                else
                {
                    MessageBox.Show("Hủy th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                    this.f_setcontrol_xuatbanle(long.Parse(this.txtsophieu.Tag.ToString()));
                    this.f_loaddata_xuatbanlect(long.Parse(this.txtsophieu.Tag.ToString()));
                    this.f_Control_enable(false);
                }
            }
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            if (this.bbiinphieu.Visibility != BarItemVisibility.Never)
            {
                DataTable table = this._xuatban.f_loaddata_xuatban(long.Parse(this.txtsophieu.Tag.ToString()), "", "");
                table.TableName = "sophieu";
                DataTable table2 = this._xuatban.f_loaddata_xuatbanct(long.Parse(this.txtsophieu.Tag.ToString()));
                table2.TableName = "chitiet";
                table2.Columns.Add("sophieu");
                table2.Columns.Add("tennguoidangnhap");
                table2.Columns.Add("hoten");
                table2.Columns.Add("solanin");
                for (int i = 0; i < table2.Rows.Count; i++)
                {
                    table2.Rows[i]["sophieu"] = this.txtsophieu.Text;
                    table2.Rows[i]["tennguoidangnhap"] = table.Rows[0]["tennguoidangnhap"].ToString();
                    table2.Rows[i]["hoten"] = "Kh\x00e1ch lẻ";
                    table2.Rows[i]["solanin"] = table.Rows[0]["solanin"].ToString();
                }
                DataSet data = new DataSet();
                data.Tables.Add(table2.Copy());
                //data.WriteXml("dataxml//d_inphieuxuatbanle.xml", XmlWriteMode.WriteSchema);
                XtraReport1 report = new XtraReport1();
                try
                {
                    bool editValue = (bool) this.bbixemtruocin.EditValue;
                    report.bPrinting = !editValue;
                }
                catch
                {
                }
                report.f_load(data, "d_in_phieuxuatbanle.repx");
                if (report.pPrintingCount > 0)
                {
                    this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
                    this._dtobanle.pID = long.Parse(this.txtsophieu.Tag.ToString());
                    this._dtobanle.Load();
                    this._dtobanle.pSOLANIN += report.pPrintingCount;
                    this._dtobanle.Update();
                }
            }
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                XtraUserControl control2 = (XtraUserControl) base.Parent;
                control2.Controls.Remove(this);
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            if (this.bbiluu.Visibility != BarItemVisibility.Never)
            {
                dtoDXuatBanLeCT ect = new dtoDXuatBanLeCT(this._xuli.pConFigData);
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                dataSource.AcceptChanges();
                for (int i = 0; i < (dataSource.Rows.Count - 1); i++)
                {
                    for (int k = i + 1; k < dataSource.Rows.Count; k++)
                    {
                        if (dataSource.Rows[i][this.gridds_id.FieldName].ToString() == dataSource.Rows[k][this.gridds_id.FieldName].ToString())
                        {
                            dataSource.Rows[i][this.gridds_soluong.FieldName] = decimal.Parse(dataSource.Rows[i][this.gridds_soluong.FieldName].ToString()) + decimal.Parse(dataSource.Rows[k][this.gridds_soluong.FieldName].ToString());
                            dataSource.Rows.RemoveAt(k--);
                        }
                    }
                }
                dtoDXuatBanLeCT[] chitiet = new dtoDXuatBanLeCT[dataSource.Rows.Count];
                for (int j = 0; j < dataSource.Rows.Count; j++)
                {
                    ect = new dtoDXuatBanLeCT(this._xuli.pConFigData);
                    try
                    {
                        ect.pDONGIA = decimal.Parse(dataSource.Rows[j][this.gridds_dongia.FieldName].ToString());
                    }
                    catch
                    {
                        ect.pDONGIA = 0M;
                    }
                    ect.pSOLUONG = decimal.Parse(dataSource.Rows[j][this.gridds_soluong.FieldName].ToString());
                    ect.pIDDUOCPHAM = int.Parse(dataSource.Rows[j][this.gridds_id.FieldName].ToString());
                    ect.pIDXUATKHOBANLE = long.Parse(this.txtsophieu.Tag.ToString());
                    ect.pIDDANGNHAP = this._iiddangnhap;
                    ect.pTHUE = decimal.Parse(dataSource.Rows[j][this.gridds_thue.FieldName].ToString());
                    chitiet[j] = ect;
                }
                dtoDXuatBanLe xuatban = new dtoDXuatBanLe(this._xuli.pConFigData) {
                    pHOTEN = "Kh\x00e1ch lẻ",
                    pID = long.Parse(this.txtsophieu.Tag.ToString()),
                    pIDDANGNHAP = this._iiddangnhap,
                    pIDNHOMKHACHHANG = this.cbbnhomkh.EditValue.GetHashCode(),
                    pNGAY = this.datengay.Text,
                    pTENMAYTINH = Environment.MachineName
                };
                try
                {
                    xuatban.pSOPHIEU = long.Parse(this.txtsophieu.Text);
                }
                catch
                {
                    xuatban.pSOPHIEU = 0L;
                }
                xuatban.pTONGTIEN = Convert.ToDecimal(this.txttongtien.EditValue);
                xuatban.pTIENKHACHDUA = Convert.ToDecimal(this.txttongthucthu.EditValue);
                xuatban.pCHIETKHAU = 0M;
                xuatban.pKIHIEU = this.txtsophieu.Text;
                xuatban.pIDLOAIXUAT = HangSo.LoaiXuatKho.enLoaiXuatKho.XuatBanKhongKeDon.GetHashCode();
                DXuatBanLe le2 = new DXuatBanLe(this._xuli.pConFigData);
                if (xuatban.pID == 0L)
                {
                    this.txtsophieu.Tag = le2.f_insert_xuatbanle(xuatban, chitiet, (HangSo.NhomKhachHang.enNhomKhachHang) this.cbbnhomkh.EditValue).ToString();
                    if (this.txtsophieu.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin phiếu xuất b\x00e1n lẻ.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    this.txtsophieu.Tag = le2.f_update_xuatbanle(xuatban, chitiet, (HangSo.NhomKhachHang.enNhomKhachHang) this.cbbnhomkh.EditValue).ToString();
                    if (this.txtsophieu.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin xuất b\x00e1n lẻ.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                this.f_setcontrol_xuatbanle(long.Parse(this.txtsophieu.Tag.ToString()));
                this.f_loaddata_xuatbanlect(long.Parse(this.txtsophieu.Tag.ToString()));
                this.f_Loaddata_dmvp();
                this.f_Control_enable(false);
            }
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            this.f_Add_ChiTiet();
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            this.f_Loadcontrol_xuatbanlechitiet(0L, 0M, 0M, 0M, 0M, 0M, 0M, "", "", "");
            base.ActiveControl = this.txtma;
        }

        private void btnmoi_Click_1(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.datengay.EditValue = DateTime.Now;
            this.f_Loadcontrol_xuatbanle(0L, "", DateTime.Now.ToString("dd/MM/yyyy HH:mm"), "", 0, 0, "", "", 0M, 0M, 0M, 0M, 0);
            this.f_loaddata_xuatbanlect(0L);
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            this.f_Loadcontrol_xuatbanlechitiet(0L, 0M, 0M, 0M, 0M, 0M, 0M, "", "", "");
            this.f_Loaddata_dmvp();
            this.txtmavach.Focus();
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.txtsophieu.Enabled = false;
            this.txtten.Focus();
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            try
            {
                this.gridView1.DeleteSelectedRows();
                this.f_tinhtongtien();
                this.f_loadinfo_chidinhchitiet(0);
            }
            catch
            {
            }
        }

        private void ctrdanhsach_vp_Validated(object sender, EventArgs e)
        {
            try
            {
                DataTable dongHienTai = this.ctrdanhsach_vp.DongHienTai;
                this.f_SetControl_dmsanpham(long.Parse(dongHienTai.Rows[0]["iddp"].ToString()));
            }
            catch
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_Add_ChiTiet()
        {
            if ((this.txtma.Tag != null) && (this.txtma.Tag.ToString() != "0"))
            {
                decimal num = Convert.ToDecimal(this.txtsoluong.EditValue);
                int idduocpham = int.Parse(this.txtma.Tag.ToString());
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                dataSource.AcceptChanges();
                if (dataSource.Select(this.gridds_id.FieldName + "=" + idduocpham).Length > 0)
                {
                    if (MessageBox.Show("T\x00ean sản phẩm '" + this.txtten.Text.ToUpper() + "' đ\x00e3 tồn tại.\nBạn c\x00f3 muốn cập nhật th\x00eam số lượng của sản phẩm n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                    {
                        return;
                    }
                    for (int j = 0; j < dataSource.Rows.Count; j++)
                    {
                        if (dataSource.Rows[j][this.gridds_id.FieldName].ToString() == idduocpham.ToString())
                        {
                            num += decimal.Parse(dataSource.Rows[j][this.gridds_soluong.FieldName].ToString());
                            dataSource.Rows.RemoveAt(j--);
                        }
                    }
                }
                dataSource.AcceptChanges();
                DataTable table2 = (DataTable) this.cbbdonggoi.Properties.DataSource;
                decimal num4 = 1M;
                try
                {
                    num4 = decimal.Parse(table2.Select("id=" + this.cbbdonggoi.EditValue.ToString())[0]["soluong"].ToString());
                }
                catch
                {
                }
                DataTable table3 = new DTonKho(this._xuli.pConFigData).f_load_tonkhochitiet(HangSo.NhomKhachHang.f_get_NhomKhachHang(Convert.ToInt32(this.cbbnhomkh.EditValue)), idduocpham).Tables[0];
                decimal num5 = 0M;
                decimal num6 = num * num4;
                for (int i = 0; i < table3.Rows.Count; i++)
                {
                    num5 = 0M;
                    DataRow row = dataSource.NewRow();
                    row[this.gridds_idnhapct.FieldName] = 0;
                    row[this.gridds_ma.FieldName] = this.txtma.Text;
                    row[this.gridds_ten.FieldName] = this.txtten.Text;
                    row[this.gridds_dvt.FieldName] = this.cbbdonggoi.Text;
                    row[this.gridds_id.FieldName] = idduocpham;
                    row[this.gridds_thue.FieldName] = 0;
                    row[this.gridds_dongia.FieldName] = table3.Rows[i]["giaban"].ToString();
                    row[this.gridds_ngaysx.FieldName] = table3.Rows[i]["losx"].ToString();
                    row[this.gridds_tenvitrikho.FieldName] = table3.Rows[i]["tenvitrikho"].ToString();
                    try
                    {
                        num5 = decimal.Parse(table3.Rows[i]["soluongton"].ToString());
                    }
                    catch
                    {
                    }
                    if (Convert.ToDecimal(row[this.gridds_dongia.FieldName].ToString()) == 0M)
                    {
                        MessageBox.Show("Chưa nhập gi\x00e1 b\x00e1n cho sản phẩm n\x00e0y.", "Th\x00f4ng b\x00e1o");
                        return;
                    }
                    dataSource.Rows.Add(row);
                    if ((num5 >= num6) && (num6 > 0M))
                    {
                        row[this.gridds_soluong.FieldName] = num6;
                        num6 = 0M;
                        row[this.gridds_thanhtien.FieldName] = decimal.Parse(row[this.gridds_dongia.FieldName].ToString()) * decimal.Parse(row[this.gridds_soluong.FieldName].ToString());
                        break;
                    }
                    row[this.gridds_soluong.FieldName] = num5;
                    num6 -= num5;
                    row[this.gridds_thanhtien.FieldName] = decimal.Parse(row[this.gridds_dongia.FieldName].ToString()) * decimal.Parse(row[this.gridds_soluong.FieldName].ToString());
                }
                if (num6 > 0M)
                {
                    MessageBox.Show("Số lượng nhập vượt qu\x00e1 số lượng tồn kho (" + (num - num6) + ")", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.gridds.DataSource = dataSource;
                this.f_tinhtongtien();
            }
        }

        private void f_Control_enable(bool chophep)
        {
            if (chophep)
            {
                this.bbiluu.Visibility = this.bbiboqua.Visibility = BarItemVisibility.Always;
                this.bbiketthuc.Visibility = this.bbiinphieu.Visibility = BarItemVisibility.Never;
            }
            else
            {
                this.bbiluu.Visibility = this.bbiboqua.Visibility = BarItemVisibility.Never;
                this.bbiketthuc.Visibility = this.bbiinphieu.Visibility = BarItemVisibility.Always;
            }
            this.btnthem.Enabled = this.btnxoa.Enabled = chophep;
            this.datengay.Properties.ReadOnly = !chophep;
        }

        private void f_load_nhomkh()
        {
            try
            {
                this.cbbnhomkh.Properties.DataSource = HangSo.NhomKhachHang.f_DanhSach();
                this.cbbnhomkh.Properties.DisplayMember = "ten";
                this.cbbnhomkh.Properties.ValueMember = "id";
                this.cbbnhomkh.EditValue = HangSo.LoaiXuatKho.enLoaiXuatKho.XuatBanKhongKeDon.GetHashCode();
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_dmvp(long id, string ma, string ten, string tenhoatchat, string dvt, decimal dongia)
        {
            this.txtma.Text = ma;
            this.txtma.Tag = id.ToString();
            this.txtten.Text = ten;
            this.txtmavach.Text = tenhoatchat;
            try
            {
                this.cbbdonggoi.Properties.DataSource = new DDuocPham().f_loaddata_dmdonggoi(Convert.ToInt32(id));
                this.cbbdonggoi.Properties.DisplayMember = "ten";
                this.cbbdonggoi.Properties.ValueMember = "id";
                this.cbbdonggoi.ItemIndex = 0;
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_xuatbanle(long id, string sophieu, string ngay, string hoten, int gioitinh, int tuoi, string namsinh, string diachi, decimal miengiam, decimal tongmiengiam, decimal tongtien, decimal tongthucthu, int nhomkhachhang)
        {
            this.txtsophieu.Tag = id.ToString();
            this.txtsophieu.Text = sophieu;
            try
            {
                this.datengay.EditValue = new DateTime(int.Parse(ngay.Substring(6, 4)), int.Parse(ngay.Substring(3, 2)), int.Parse(ngay.Substring(0, 2)), int.Parse(ngay.Substring(11, 2)), int.Parse(ngay.Substring(14, 2)), 0);
            }
            catch
            {
            }
            this.txttongtien.EditValue = tongtien;
            this.cbbnhomkh.EditValue = nhomkhachhang;
        }

        private void f_Loadcontrol_xuatbanlechitiet(long id, decimal soluong, decimal dongia, decimal sotien, decimal thue, decimal tienthue, decimal giaban, string losx, string hangsx, string tenvitrikho)
        {
            this.lblmaso.Tag = id.ToString();
            this.txtsoluong.EditValue = soluong;
        }

        private void f_Loaddata_dmvp()
        {
            try
            {
                this.ctrdanhsach_vp.SetDataSource = new DTonKho(this._xuli.pConFigData).f_load_tonkhotonghop().Tables[0];
                this.ctrdanhsach_vp.DanhSachCotHienThi = "madp,tendp,dvt,soluongton";
            }
            catch
            {
            }
        }

        private void f_loaddata_xuatbanlect(long idxuatban)
        {
            DataTable table = this._xuatban.f_loaddata_xuatbanct(idxuatban);
            this.gridds.DataSource = table;
            decimal num = 0M;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                num += decimal.Parse(table.Rows[i][this.gridds_thanhtien.FieldName].ToString()) * (1+decimal.Parse(table.Rows[i][this.gridds_thue.FieldName].ToString()) / 100M);
            }
            this.txttongtien.EditValue = num;
            this.f_tinhtongtien();
            this.txttongthucthu.EditValue = 0;
            this.txttongtienthua.EditValue = 0;
        }

        private void f_loadinfo_chidinhchitiet(int indexrow)
        {
            try
            {
                this.f_Loadcontrol_dmvp(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_id).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ma).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_tenhoatchat).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dvt).ToString(), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()));
                this.f_Loadcontrol_xuatbanlechitiet(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idnhapct).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_soluong).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thanhtien).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thue).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thanhtien).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_giaban).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ngaysx).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_hangsx).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_tenvitrikho).ToString());
            }
            catch
            {
            }
        }

        private void f_SetControl_dmsanpham(long idvp)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("iddp=" + idvp.ToString());
                this.f_Loadcontrol_dmvp(idvp, rowArray[0]["madp"].ToString(), rowArray[0]["tendp"].ToString(), rowArray[0]["mavach"].ToString(), rowArray[0]["dvt"].ToString(), decimal.Parse(rowArray[0]["giaban"].ToString()));
                txtsoluong.EditValue = 1;
            }
            catch
            {
                this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            }
        }

        private void f_setcontrol_xuatbanle(long id)
        {
            dtoDXuatBanLe le = new dtoDXuatBanLe(this._xuli.pConFigData) {
                pID = id
            };
            le.Load();
            try
            {
                decimal tongmiengiam = (le.pCHIETKHAU / 100M) * le.pTONGTIEN;
                this.f_Loadcontrol_xuatbanle(le.pID, le.pKIHIEU.ToString(), le.pNGAY, le.pHOTEN, le.pIDGIOITINH, 0, le.pNAMSINH, le.pDIACHI, le.pCHIETKHAU, tongmiengiam, le.pTONGTIEN, le.pTONGTIEN - tongmiengiam, le.pIDNHOMKHACHHANG);
            }
            catch
            {
                this.f_Loadcontrol_xuatbanle(0L, "", DateTime.Now.ToString("dd/MM/yyyy HH:mm"), "", HangSo.enGioiTinh.Nam.GetHashCode(), 0, "", "", 0M, 0M, 0M, 0M, 0);
            }
        }

        private void f_tinhtongtien()
        {
            try
            {
                decimal num = 0M;
                decimal num2 = 0M;
                decimal num3 = 0M;
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                for (int i = 0; i < dataSource.Rows.Count; i++)
                {
                    num += decimal.Parse(dataSource.Rows[i][this.gridds_thanhtien.FieldName].ToString());
                }
                this.txttongtien.EditValue = num;
                this.txttongchietkhau.EditValue = num2;
                this.txttongvat.EditValue = num3;
                this.txttongthanhtoan.EditValue = (num + num3) - num2;
                this.txttongthucthu.EditValue = Convert.ToDecimal(this.txttongthanhtoan.EditValue);
                this.txttongtienthua.EditValue = ((num + num3) - num2) - Convert.ToDecimal(this.txttongthucthu.EditValue);
            }
            catch
            {
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                if (this.gridView1.IsFocusedView)
                {
                    indexrow = this.gridView1.GetSelectedRows()[0];
                    this.f_loadinfo_chidinhchitiet(indexrow);
                }
            }
            catch
            {
            }
        }

        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucd_xuatkho_banle_ll_khonghoadon));
            StyleFormatCondition condition = new StyleFormatCondition();
            this.gridds_dongia = new GridColumn();
            this.repositoryItemTextEdit2 = new RepositoryItemTextEdit();
            this.lblmaso = new Label();
            this.txtma = new TextEdit();
            this.txtten = new TextEdit();
            this.btnthem = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.gridds_ten = new GridColumn();
            this.gridds_dvt = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_soluong = new GridColumn();
            this.gridds_thanhtien = new GridColumn();
            this.gridds_idnhapct = new GridColumn();
            this.gridds_slxuat = new GridColumn();
            this.gridds_tenhoatchat = new GridColumn();
            this.gridds_giaban = new GridColumn();
            this.gridds_ngaysx = new GridColumn();
            this.gridds_hangsx = new GridColumn();
            this.gridds_idvitrikho = new GridColumn();
            this.gridds_thue = new GridColumn();
            this.gridds_tongtien = new GridColumn();
            this.gridds_tenvitrikho = new GridColumn();
            this.gridds = new GridControl();
            this.label1 = new Label();
            this.txtsophieu = new TextEdit();
            this.ctrdanhsach_vp = new ctrdanhsach();
            this.txtmavach = new TextEdit();
            this.label2 = new Label();
            this.label14 = new Label();
            this.label8 = new Label();
            this.datengay = new DateEdit();
            this.label19 = new Label();
            this.btnxoa = new SimpleButton();
            this.groupControl1 = new GroupControl();
            this.cbbnhomkh = new LookUpEdit();
            this.label28 = new Label();
            this.txttongchietkhau = new TextEdit();
            this.txttongvat = new TextEdit();
            this.txttongtienthua = new TextEdit();
            this.txttongthucthu = new TextEdit();
            this.txttongthanhtoan = new TextEdit();
            this.txttongtien = new TextEdit();
            this.label4 = new Label();
            this.label3 = new Label();
            this.lblthuathieu = new Label();
            this.label6 = new Label();
            this.label5 = new Label();
            this.groupControl2 = new GroupControl();
            this.cbbdonggoi = new LookUpEdit();
            this.txtsoluong = new TextEdit();
            this.standaloneBarDockControl1 = new StandaloneBarDockControl();
            this.barManager1 = new BarManager(this.components);
            this.bar1 = new Bar();
            this.bbiluu = new BarButtonItem();
            this.bbiboqua = new BarButtonItem();
            this.bbiinphieu = new BarButtonItem();
            this.bbiketthuc = new BarButtonItem();
            this.bbixemtruocin = new BarEditItem();
            this.repositoryItemCheckEdit3 = new RepositoryItemCheckEdit();
            this.barDockControlTop = new BarDockControl();
            this.barDockControlBottom = new BarDockControl();
            this.barDockControlLeft = new BarDockControl();
            this.barDockControlRight = new BarDockControl();
            this.barCheckItem1 = new BarCheckItem();
            this.barSubItem1 = new BarSubItem();
            this.barEditItem1 = new BarEditItem();
            this.repositoryItemCheckEdit1 = new RepositoryItemCheckEdit();
            this.barEditItem2 = new BarEditItem();
            this.repositoryItemCheckEdit2 = new RepositoryItemCheckEdit();
            this.barEditItem3 = new BarEditItem();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.barEditItem4 = new BarEditItem();
            this.repositoryItemTextEdit3 = new RepositoryItemTextEdit();
            this.barEditItem5 = new BarEditItem();
            this.repositoryItemTextEdit4 = new RepositoryItemTextEdit();
            this.barCheckItem2 = new BarCheckItem();
            this.bbithuockhongkedon = new BarEditItem();
            this.repositoryItemCheckEdit4 = new RepositoryItemCheckEdit();
            this.repositoryItemTextEdit2.BeginInit();
            this.txtma.Properties.BeginInit();
            this.txtten.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.gridds.BeginInit();
            this.txtsophieu.Properties.BeginInit();
            this.txtmavach.Properties.BeginInit();
            this.datengay.Properties.VistaTimeProperties.BeginInit();
            this.datengay.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.cbbnhomkh.Properties.BeginInit();
            this.txttongchietkhau.Properties.BeginInit();
            this.txttongvat.Properties.BeginInit();
            this.txttongtienthua.Properties.BeginInit();
            this.txttongthucthu.Properties.BeginInit();
            this.txttongthanhtoan.Properties.BeginInit();
            this.txttongtien.Properties.BeginInit();
            this.groupControl2.BeginInit();
            this.groupControl2.SuspendLayout();
            this.cbbdonggoi.Properties.BeginInit();
            this.txtsoluong.Properties.BeginInit();
            this.barManager1.BeginInit();
            this.repositoryItemCheckEdit3.BeginInit();
            this.repositoryItemCheckEdit1.BeginInit();
            this.repositoryItemCheckEdit2.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.repositoryItemTextEdit3.BeginInit();
            this.repositoryItemTextEdit4.BeginInit();
            this.repositoryItemCheckEdit4.BeginInit();
            base.SuspendLayout();
            this.gridds_dongia.Caption = "Đơn gi\x00e1";
            this.gridds_dongia.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_dongia.FieldName = "giaban";
            this.gridds_dongia.Name = "gridds_dongia";
            this.gridds_dongia.Visible = true;
            this.gridds_dongia.VisibleIndex = 3;
            this.gridds_dongia.Width = 0x42;
            this.repositoryItemTextEdit2.AutoHeight = false;
            this.repositoryItemTextEdit2.DisplayFormat.FormatString = "n0";
            this.repositoryItemTextEdit2.DisplayFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.EditFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.Mask.EditMask = "n0";
            this.repositoryItemTextEdit2.Mask.MaskType = MaskType.Numeric;
            this.repositoryItemTextEdit2.Name = "repositoryItemTextEdit2";
            this.lblmaso.Font = new Font("Tahoma", 10f);
            this.lblmaso.Location = new Point(0xf2, 0x1c);
            this.lblmaso.Name = "lblmaso";
            this.lblmaso.Size = new Size(0x60, 0x13);
            this.lblmaso.TabIndex = 2;
            this.lblmaso.Text = "Sản phẩm:";
            this.lblmaso.TextAlign = ContentAlignment.TopRight;
            this.txtma.Location = new Point(0x14e, 0x1b);
            this.txtma.Name = "txtma";
            this.txtma.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtma.Size = new Size(0x38, 20);
            this.txtma.TabIndex = 1;
            this.txtma.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtma.Validated += new EventHandler(this.txtma_Validated);
            this.txtten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtten.Location = new Point(0x188, 0x1b);
            this.txtten.Name = "txtten";
            this.txtten.Size = new Size(0x149, 20);
            this.txtten.TabIndex = 2;
            this.txtten.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txtten.Enter += new EventHandler(this.txtten_Enter);
            this.txtten.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txtten.Validated += new EventHandler(this.txtten_Validated);
            this.btnthem.Appearance.Options.UseTextOptions = true;
            this.btnthem.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnthem.Image = Resources.Reso.imgadd;// (Image)manager.GetObject("btnthem.Image");
            this.btnthem.Location = new Point(0x60, 0x53);
            this.btnthem.Name = "btnthem";
            this.btnthem.Size = new Size(0x4b, 0x17);
            this.btnthem.TabIndex = 6;
            this.btnthem.Text = " &Th\x00eam [F1]";
            this.btnthem.Click += new EventHandler(this.btnmoi_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x7a, 0x72, 0x71);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(200, 0xc0, 0x9d);
            this.gridView1.Appearance.FocusedRow.BorderColor = Color.FromArgb(0xe2, 0xdb, 0xbc);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf6, 0xf2, 0xd5);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.Black;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(0xfb, 0xfc, 0xf7);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x94, 0x94, 0x94);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0xdd, 0xd7, 0xbc);
            this.gridView1.Appearance.SelectedRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { 
                this.gridds_ma, this.gridds_ten, this.gridds_dvt, this.gridds_id, this.gridds_dongia, this.gridds_soluong, this.gridds_thanhtien, this.gridds_idnhapct, this.gridds_slxuat, this.gridds_tenhoatchat, this.gridds_giaban, this.gridds_ngaysx, this.gridds_hangsx, this.gridds_idvitrikho, this.gridds_thue, this.gridds_tongtien, 
                this.gridds_tenvitrikho
             });
            condition.Appearance.ForeColor = Color.Red;
            condition.Appearance.Options.UseForeColor = true;
            condition.Column = this.gridds_dongia;
            condition.Condition = FormatConditionEnum.Between;
            condition.Value1 = "0";
            condition.Value2 = "0";
            this.gridView1.FormatConditions.AddRange(new StyleFormatCondition[] { condition });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsBehavior.AllowAddRows = DefaultBoolean.True;
            this.gridView1.OptionsBehavior.AllowDeleteRows = DefaultBoolean.False;
            this.gridView1.OptionsBehavior.ReadOnly = true;
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.RowCellStyle += new RowCellStyleEventHandler(this.gridView1_RowCellStyle);
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_ma.FieldName = "madp";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "Cộng: {0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 0;
            this.gridds_ma.Width = 0x3d;
            this.gridds_ten.Caption = "T\x00ean sản phẩm";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_ten.FieldName = "tendp";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 0x14d;
            this.gridds_dvt.Caption = "ĐVT";
            this.gridds_dvt.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_dvt.FieldName = "dvt";
            this.gridds_dvt.Name = "gridds_dvt";
            this.gridds_dvt.OptionsColumn.AllowEdit = false;
            this.gridds_dvt.Visible = true;
            this.gridds_dvt.VisibleIndex = 2;
            this.gridds_dvt.Width = 0x27;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "iddp";
            this.gridds_id.Name = "gridds_id";
            this.gridds_soluong.Caption = "SL";
            this.gridds_soluong.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_soluong.FieldName = "soluong";
            this.gridds_soluong.Name = "gridds_soluong";
            this.gridds_soluong.Visible = true;
            this.gridds_soluong.VisibleIndex = 4;
            this.gridds_soluong.Width = 0x25;
            this.gridds_thanhtien.Caption = "Số tiền";
            this.gridds_thanhtien.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_thanhtien.FieldName = "thanhtien";
            this.gridds_thanhtien.Name = "gridds_thanhtien";
            this.gridds_thanhtien.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, "thanhtien", "Tổng: {0:n0}") });
            this.gridds_thanhtien.Visible = true;
            this.gridds_thanhtien.VisibleIndex = 5;
            this.gridds_thanhtien.Width = 100;
            this.gridds_idnhapct.Caption = "idnhapct";
            this.gridds_idnhapct.FieldName = "id";
            this.gridds_idnhapct.Name = "gridds_idnhapct";
            this.gridds_slxuat.Caption = "sldathanhtoan";
            this.gridds_slxuat.FieldName = "soluongxuat";
            this.gridds_slxuat.Name = "gridds_slxuat";
            this.gridds_tenhoatchat.Caption = "tenhoatchat";
            this.gridds_tenhoatchat.FieldName = "tenhoatchat";
            this.gridds_tenhoatchat.Name = "gridds_tenhoatchat";
            this.gridds_giaban.Caption = "giaban";
            this.gridds_giaban.FieldName = "giaban";
            this.gridds_giaban.Name = "gridds_giaban";
            this.gridds_ngaysx.Caption = "Ng\x00e0y SX";
            this.gridds_ngaysx.FieldName = "losx";
            this.gridds_ngaysx.Name = "gridds_ngaysx";
            this.gridds_ngaysx.Visible = true;
            this.gridds_ngaysx.VisibleIndex = 6;
            this.gridds_hangsx.Caption = "hangsx";
            this.gridds_hangsx.FieldName = "hangsx";
            this.gridds_hangsx.Name = "gridds_hangsx";
            this.gridds_idvitrikho.Caption = "idvitrikho";
            this.gridds_idvitrikho.FieldName = "idvitrikho";
            this.gridds_idvitrikho.Name = "gridds_idvitrikho";
            this.gridds_thue.Caption = "Thuế %";
            this.gridds_thue.FieldName = "thue";
            this.gridds_thue.Name = "gridds_thue";
            this.gridds_thue.Width = 0x33;
            this.gridds_tongtien.Caption = "Th\x00e0nh tiền";
            this.gridds_tongtien.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_tongtien.FieldName = "tiensauthue";
            this.gridds_tongtien.Name = "gridds_tongtien";
            this.gridds_tongtien.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, "tiensauthue", "Tổng: {0:n0}") });
            this.gridds_tongtien.Width = 0x5f;
            this.gridds_tenvitrikho.Caption = "Vị tr\x00ed trong kho";
            this.gridds_tenvitrikho.FieldName = "tenvitrikho";
            this.gridds_tenvitrikho.Name = "gridds_tenvitrikho";
            this.gridds_tenvitrikho.Width = 0x107;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(0, 0x71);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.Size = new Size(0x2d4, 0x145);
            this.gridds.TabIndex = 7;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.gridds.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label1.Font = new Font("Tahoma", 10f);
            this.label1.Location = new Point(0x19, 0x36);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x60, 0x13);
            this.label1.TabIndex = 2;
            this.label1.Text = "Số phiếu:";
            this.label1.TextAlign = ContentAlignment.TopRight;
            this.txtsophieu.Location = new Point(0x80, 0x35);
            this.txtsophieu.Name = "txtsophieu";
            this.txtsophieu.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtsophieu.Properties.MaxLength = 10;
            this.txtsophieu.Size = new Size(0x9a, 20);
            this.txtsophieu.TabIndex = 1;
            this.txtsophieu.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.ctrdanhsach_vp.ChieuRongTuDong = true;
            this.ctrdanhsach_vp.DanhSachCotHienThi = "";
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = "";
            this.ctrdanhsach_vp.Location = new Point(0x1ba, 0x30);
            this.ctrdanhsach_vp.Name = "ctrdanhsach_vp";
            this.ctrdanhsach_vp.pRowsCountDown = 5;
            this.ctrdanhsach_vp.Size = new Size(60, 0x13);
            this.ctrdanhsach_vp.TabIndex = 3;
            this.ctrdanhsach_vp.Visible = false;
            this.ctrdanhsach_vp.Validated += new EventHandler(this.ctrdanhsach_vp_Validated);
            this.txtmavach.Location = new Point(0x60, 0x1b);
            this.txtmavach.Name = "txtmavach";
            this.txtmavach.Size = new Size(0x8f, 20);
            this.txtmavach.TabIndex = 0;
            this.txtmavach.Enter += new EventHandler(this.txtmavach_Enter);
            this.txtmavach.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtmavach.Validated += new EventHandler(this.txttenhoatchat_Validated);
            this.label2.Font = new Font("Tahoma", 10f);
            this.label2.Location = new Point(0x15, 0x1c);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x4f, 0x13);
            this.label2.TabIndex = 2;
            this.label2.Text = "M\x00e3 vạch:";
            this.label2.TextAlign = ContentAlignment.TopRight;
            this.label14.Font = new Font("Tahoma", 10f);
            this.label14.Location = new Point(7, 0x38);
            this.label14.Name = "label14";
            this.label14.Size = new Size(0x5d, 0x13);
            this.label14.TabIndex = 2;
            this.label14.Text = "Số lượng:";
            this.label14.TextAlign = ContentAlignment.TopRight;
            this.label8.Font = new Font("Tahoma", 10f);
            this.label8.Location = new Point(0x2d, 0x1b);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x4d, 0x13);
            this.label8.TabIndex = 2;
            this.label8.Text = "Ng\x00e0y:";
            this.label8.TextAlign = ContentAlignment.TopRight;
            this.datengay.EditValue = new DateTime(0x7dd, 11, 8, 2, 0x16, 9, 0x297);
            this.datengay.Location = new Point(0x80, 0x1b);
            this.datengay.Name = "datengay";
            this.datengay.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.datengay.Properties.DisplayFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datengay.Properties.DisplayFormat.FormatType = FormatType.DateTime;
            this.datengay.Properties.EditFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datengay.Properties.EditFormat.FormatType = FormatType.DateTime;
            this.datengay.Properties.Mask.EditMask = "dd/MM/yyyy HH:mm";
            this.datengay.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.datengay.Size = new Size(0x9a, 20);
            this.datengay.TabIndex = 0;
            this.datengay.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label19.Font = new Font("Tahoma", 14f);
            this.label19.ForeColor = Color.FromArgb(0x40, 0x40, 0x40);
            this.label19.Location = new Point(2, 0x53);
            this.label19.Name = "label19";
            this.label19.Size = new Size(0x80, 0x1b);
            this.label19.TabIndex = 2;
            this.label19.Text = "Cộng tiền:";
            this.label19.TextAlign = ContentAlignment.TopRight;
            this.btnxoa.Image = Resources.Reso.imgdelete2;// (Image)manager.GetObject("btnxoa.Image");
            this.btnxoa.Location = new Point(0xad, 0x53);
            this.btnxoa.Name = "btnxoa";
            this.btnxoa.Size = new Size(0x42, 0x17);
            this.btnxoa.TabIndex = 8;
            this.btnxoa.Text = " &X\x00f3a";
            this.btnxoa.Click += new EventHandler(this.btnxoa_Click);
            this.groupControl1.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.groupControl1.AppearanceCaption.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.groupControl1.AppearanceCaption.Options.UseFont = true;
            this.groupControl1.Controls.Add(this.cbbnhomkh);
            this.groupControl1.Controls.Add(this.label28);
            this.groupControl1.Controls.Add(this.txttongchietkhau);
            this.groupControl1.Controls.Add(this.txttongvat);
            this.groupControl1.Controls.Add(this.txttongtienthua);
            this.groupControl1.Controls.Add(this.txttongthucthu);
            this.groupControl1.Controls.Add(this.txttongthanhtoan);
            this.groupControl1.Controls.Add(this.txttongtien);
            this.groupControl1.Controls.Add(this.label8);
            this.groupControl1.Controls.Add(this.txtsophieu);
            this.groupControl1.Controls.Add(this.label4);
            this.groupControl1.Controls.Add(this.label3);
            this.groupControl1.Controls.Add(this.lblthuathieu);
            this.groupControl1.Controls.Add(this.label6);
            this.groupControl1.Controls.Add(this.label5);
            this.groupControl1.Controls.Add(this.datengay);
            this.groupControl1.Controls.Add(this.label19);
            this.groupControl1.Controls.Add(this.label1);
            this.groupControl1.Location = new Point(1, 0x29);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x125, 0x1b5);
            this.groupControl1.TabIndex = 1;
            this.groupControl1.Text = "Số phiếu";
            this.cbbnhomkh.Location = new Point(0x80, 0x145);
            this.cbbnhomkh.Name = "cbbnhomkh";
            this.cbbnhomkh.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbnhomkh.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("ten", "T\x00ean") });
            this.cbbnhomkh.Size = new Size(0x8b, 20);
            this.cbbnhomkh.TabIndex = 9;
            this.cbbnhomkh.Visible = false;
            this.label28.Font = new Font("Tahoma", 10f);
            this.label28.Location = new Point(0x30, 0x147);
            this.label28.Name = "label28";
            this.label28.Size = new Size(0x53, 0x13);
            this.label28.TabIndex = 8;
            this.label28.Text = "Nh\x00f3m KH:";
            this.label28.TextAlign = ContentAlignment.TopRight;
            this.label28.Visible = false;
            this.txttongchietkhau.Enabled = false;
            this.txttongchietkhau.Location = new Point(0x80, 0x8f);
            this.txttongchietkhau.Name = "txttongchietkhau";
            this.txttongchietkhau.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.txttongchietkhau.Properties.Appearance.Options.UseFont = true;
            this.txttongchietkhau.Properties.DisplayFormat.FormatString = "n0";
            this.txttongchietkhau.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongchietkhau.Properties.EditFormat.FormatString = "n0";
            this.txttongchietkhau.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongchietkhau.Properties.Mask.EditMask = "n0";
            this.txttongchietkhau.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongchietkhau.Size = new Size(0x9a, 0x16);
            this.txttongchietkhau.TabIndex = 4;
            this.txttongvat.Enabled = false;
            this.txttongvat.Location = new Point(0x80, 0x74);
            this.txttongvat.Name = "txttongvat";
            this.txttongvat.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.txttongvat.Properties.Appearance.Options.UseFont = true;
            this.txttongvat.Properties.DisplayFormat.FormatString = "n0";
            this.txttongvat.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongvat.Properties.EditFormat.FormatString = "n0";
            this.txttongvat.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongvat.Properties.Mask.EditMask = "n0";
            this.txttongvat.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongvat.Size = new Size(0x9a, 0x16);
            this.txttongvat.TabIndex = 3;
            this.txttongtienthua.Enabled = false;
            this.txttongtienthua.Location = new Point(0x80, 0x121);
            this.txttongtienthua.Name = "txttongtienthua";
            this.txttongtienthua.Properties.Appearance.Font = new Font("Tahoma", 14f);
            this.txttongtienthua.Properties.Appearance.ForeColor = Color.Green;
            this.txttongtienthua.Properties.Appearance.Options.UseFont = true;
            this.txttongtienthua.Properties.Appearance.Options.UseForeColor = true;
            this.txttongtienthua.Properties.DisplayFormat.FormatString = "n0";
            this.txttongtienthua.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongtienthua.Properties.EditFormat.FormatString = "n0";
            this.txttongtienthua.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongtienthua.Properties.Mask.EditMask = "n0";
            this.txttongtienthua.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongtienthua.Size = new Size(0x9a, 30);
            this.txttongtienthua.TabIndex = 7;
            this.txttongthucthu.Location = new Point(0x80, 0xf7);
            this.txttongthucthu.Name = "txttongthucthu";
            this.txttongthucthu.Properties.Appearance.BackColor = Color.LemonChiffon;
            this.txttongthucthu.Properties.Appearance.Font = new Font("Tahoma", 14f);
            this.txttongthucthu.Properties.Appearance.ForeColor = Color.Red;
            this.txttongthucthu.Properties.Appearance.Options.UseBackColor = true;
            this.txttongthucthu.Properties.Appearance.Options.UseFont = true;
            this.txttongthucthu.Properties.Appearance.Options.UseForeColor = true;
            this.txttongthucthu.Properties.DisplayFormat.FormatString = "n0";
            this.txttongthucthu.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongthucthu.Properties.EditFormat.FormatString = "n0";
            this.txttongthucthu.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongthucthu.Properties.Mask.EditMask = "n0";
            this.txttongthucthu.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongthucthu.Size = new Size(0x9a, 30);
            this.txttongthucthu.TabIndex = 6;
            this.txttongthucthu.EditValueChanged += new EventHandler(this.txttongthucthu_EditValueChanged);
            this.txttongthucthu.Click += new EventHandler(this.txttongthucthu_Click);
            this.txttongthucthu.Enter += new EventHandler(this.txttongthucthu_Enter);
            this.txttongthucthu.Validated += new EventHandler(this.txttongthucthu_Validated);
            this.txttongthanhtoan.Enabled = false;
            this.txttongthanhtoan.Location = new Point(0x80, 0xd3);
            this.txttongthanhtoan.Name = "txttongthanhtoan";
            this.txttongthanhtoan.Properties.Appearance.BackColor = Color.LemonChiffon;
            this.txttongthanhtoan.Properties.Appearance.Font = new Font("Tahoma", 14f);
            this.txttongthanhtoan.Properties.Appearance.Options.UseBackColor = true;
            this.txttongthanhtoan.Properties.Appearance.Options.UseFont = true;
            this.txttongthanhtoan.Properties.DisplayFormat.FormatString = "n0";
            this.txttongthanhtoan.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongthanhtoan.Properties.EditFormat.FormatString = "n0";
            this.txttongthanhtoan.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongthanhtoan.Properties.Mask.EditMask = "n0";
            this.txttongthanhtoan.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongthanhtoan.Size = new Size(0x9a, 30);
            this.txttongthanhtoan.TabIndex = 5;
            this.txttongtien.Enabled = false;
            this.txttongtien.Location = new Point(0x80, 80);
            this.txttongtien.Name = "txttongtien";
            this.txttongtien.Properties.Appearance.Font = new Font("Tahoma", 14f);
            this.txttongtien.Properties.Appearance.Options.UseFont = true;
            this.txttongtien.Properties.DisplayFormat.FormatString = "n0";
            this.txttongtien.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txttongtien.Properties.EditFormat.FormatString = "n0";
            this.txttongtien.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txttongtien.Properties.Mask.EditMask = "n0";
            this.txttongtien.Properties.Mask.MaskType = MaskType.Numeric;
            this.txttongtien.Size = new Size(0x9a, 30);
            this.txttongtien.TabIndex = 2;
            this.label4.Font = new Font("Tahoma", 10f);
            this.label4.Location = new Point(3, 0x92);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x79, 0x13);
            this.label4.TabIndex = 2;
            this.label4.Text = "Tiền chiết khấu:";
            this.label4.TextAlign = ContentAlignment.TopRight;
            this.label3.Font = new Font("Tahoma", 10f);
            this.label3.Location = new Point(3, 0x77);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x79, 0x13);
            this.label3.TabIndex = 2;
            this.label3.Text = "Tiền VAT:";
            this.label3.TextAlign = ContentAlignment.TopRight;
            this.lblthuathieu.Font = new Font("Tahoma", 14f);
            this.lblthuathieu.ForeColor = Color.Green;
            this.lblthuathieu.Location = new Point(12, 0x124);
            this.lblthuathieu.Name = "lblthuathieu";
            this.lblthuathieu.Size = new Size(0x76, 0x1b);
            this.lblthuathieu.TabIndex = 2;
            this.lblthuathieu.Text = "Tiền thừa:";
            this.lblthuathieu.TextAlign = ContentAlignment.TopRight;
            this.label6.Font = new Font("Tahoma", 14f);
            this.label6.ForeColor = Color.Red;
            this.label6.Location = new Point(12, 250);
            this.label6.Name = "label6";
            this.label6.Size = new Size(0x76, 0x1b);
            this.label6.TabIndex = 2;
            this.label6.Text = "Thanh to\x00e1n:";
            this.label6.TextAlign = ContentAlignment.TopRight;
            this.label5.Font = new Font("Tahoma", 14f);
            this.label5.ForeColor = Color.Blue;
            this.label5.Location = new Point(80, 0xb5);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0xca, 0x1b);
            this.label5.TabIndex = 2;
            this.label5.Text = "Tổng tiền thanh to\x00e1n:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            this.groupControl2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.groupControl2.AppearanceCaption.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.groupControl2.AppearanceCaption.Options.UseFont = true;
            this.groupControl2.Controls.Add(this.cbbdonggoi);
            this.groupControl2.Controls.Add(this.txtsoluong);
            this.groupControl2.Controls.Add(this.gridds);
            this.groupControl2.Controls.Add(this.txtten);
            this.groupControl2.Controls.Add(this.ctrdanhsach_vp);
            this.groupControl2.Controls.Add(this.btnxoa);
            this.groupControl2.Controls.Add(this.txtmavach);
            this.groupControl2.Controls.Add(this.txtma);
            this.groupControl2.Controls.Add(this.label14);
            this.groupControl2.Controls.Add(this.btnthem);
            this.groupControl2.Controls.Add(this.lblmaso);
            this.groupControl2.Controls.Add(this.label2);
            this.groupControl2.Location = new Point(0x127, 0x29);
            this.groupControl2.Name = "groupControl2";
            this.groupControl2.Size = new Size(0x2d6, 0x1b6);
            this.groupControl2.TabIndex = 0;
            this.groupControl2.Text = "Chi tiết";
            this.cbbdonggoi.Location = new Point(0x9a, 0x37);
            this.cbbdonggoi.Name = "cbbdonggoi";
            this.cbbdonggoi.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbdonggoi.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("ten", "T\x00ean") });
            this.cbbdonggoi.Size = new Size(0x55, 20);
            this.cbbdonggoi.TabIndex = 5;
            this.cbbdonggoi.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txtsoluong.Location = new Point(0x60, 0x35);
            this.txtsoluong.Name = "txtsoluong";
            this.txtsoluong.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.txtsoluong.Properties.Appearance.Options.UseFont = true;
            this.txtsoluong.Properties.DisplayFormat.FormatString = "n0";
            this.txtsoluong.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txtsoluong.Properties.EditFormat.FormatString = "n0";
            this.txtsoluong.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txtsoluong.Properties.Mask.EditMask = "n0";
            this.txtsoluong.Properties.Mask.MaskType = MaskType.Numeric;
            this.txtsoluong.Size = new Size(0x38, 0x16);
            this.txtsoluong.TabIndex = 4;
            this.txtsoluong.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.standaloneBarDockControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.standaloneBarDockControl1.CausesValidation = false;
            this.standaloneBarDockControl1.Location = new Point(0, 4);
            this.standaloneBarDockControl1.Name = "standaloneBarDockControl1";
            this.standaloneBarDockControl1.Size = new Size(0x400, 0x1c);
            this.standaloneBarDockControl1.Text = "standaloneBarDockControl1";
            this.barManager1.Bars.AddRange(new Bar[] { this.bar1 });
            this.barManager1.DockControls.Add(this.barDockControlTop);
            this.barManager1.DockControls.Add(this.barDockControlBottom);
            this.barManager1.DockControls.Add(this.barDockControlLeft);
            this.barManager1.DockControls.Add(this.barDockControlRight);
            this.barManager1.DockControls.Add(this.standaloneBarDockControl1);
            this.barManager1.Form = this;
            this.barManager1.Items.AddRange(new BarItem[] { this.bbiluu, this.bbiboqua, this.bbiketthuc, this.bbiinphieu, this.barCheckItem1, this.barSubItem1, this.barEditItem1, this.barEditItem2, this.barEditItem3, this.barEditItem4, this.barEditItem5, this.bbixemtruocin, this.barCheckItem2, this.bbithuockhongkedon });
            this.barManager1.MaxItemId = 14;
            this.barManager1.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemCheckEdit1, this.repositoryItemCheckEdit2, this.repositoryItemTextEdit1, this.repositoryItemTextEdit3, this.repositoryItemTextEdit4, this.repositoryItemCheckEdit3, this.repositoryItemCheckEdit4 });
            this.bar1.BarName = "Tools";
            this.bar1.DockCol = 0;
            this.bar1.DockRow = 0;
            this.bar1.DockStyle = BarDockStyle.Standalone;
            this.bar1.FloatLocation = new Point(330, 0x99);
            this.bar1.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiluu, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiboqua, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiinphieu, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiketthuc, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbixemtruocin, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph) });
            this.bar1.OptionsBar.AllowQuickCustomization = false;
            this.bar1.OptionsBar.DrawBorder = false;
            this.bar1.OptionsBar.DrawDragBorder = false;
            this.bar1.StandaloneBarDockControl = this.standaloneBarDockControl1;
            this.bar1.Text = "Tools";
            this.bbiluu.Caption = "&Lưu [F5]";
            this.bbiluu.Glyph = Resources.Reso.imgsave;// (Image)manager.GetObject("bbiluu.Glyph");
            this.bbiluu.Id = 0;
            this.bbiluu.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiluu.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiluu.Name = "bbiluu";
            this.bbiluu.ItemClick += new ItemClickEventHandler(this.bbiluu_ItemClick);
            this.bbiboqua.Caption = "&Bỏ qua [F4]";
            this.bbiboqua.Glyph = Resources.Reso.imgundo;// (Image)manager.GetObject("bbiboqua.Glyph");
            this.bbiboqua.Id = 1;
            this.bbiboqua.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiboqua.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiboqua.Name = "bbiboqua";
            this.bbiboqua.ItemClick += new ItemClickEventHandler(this.bbiboqua_ItemClick);
            this.bbiinphieu.Caption = "&In phiếu [F11]";
            this.bbiinphieu.Glyph = Resources.Reso.imgprint;// (Image)manager.GetObject("bbiinphieu.Glyph");
            this.bbiinphieu.Id = 3;
            this.bbiinphieu.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiinphieu.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiinphieu.Name = "bbiinphieu";
            this.bbiinphieu.ItemClick += new ItemClickEventHandler(this.bbiinphieu_ItemClick);
            this.bbiketthuc.Caption = "&Kết th\x00fac [F12]";
            this.bbiketthuc.Glyph = Resources.Reso.imgclose;// (Image)manager.GetObject("bbiketthuc.Glyph");
            this.bbiketthuc.Id = 2;
            this.bbiketthuc.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiketthuc.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiketthuc.Name = "bbiketthuc";
            this.bbiketthuc.ItemClick += new ItemClickEventHandler(this.bbiketthuc_ItemClick);
            this.bbixemtruocin.Caption = "&Xem trước khi in";
            this.bbixemtruocin.Edit = this.repositoryItemCheckEdit3;
            this.bbixemtruocin.EditValue = true;
            this.bbixemtruocin.Id = 11;
            this.bbixemtruocin.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbixemtruocin.ItemAppearance.Normal.Options.UseFont = true;
            this.bbixemtruocin.Name = "bbixemtruocin";
            this.bbixemtruocin.Width = 20;
            this.repositoryItemCheckEdit3.AutoHeight = false;
            this.repositoryItemCheckEdit3.Name = "repositoryItemCheckEdit3";
            this.barDockControlTop.CausesValidation = false;
            this.barDockControlTop.Dock = DockStyle.Top;
            this.barDockControlTop.Location = new Point(0, 0);
            this.barDockControlTop.Size = new Size(0x400, 0);
            this.barDockControlBottom.CausesValidation = false;
            this.barDockControlBottom.Dock = DockStyle.Bottom;
            this.barDockControlBottom.Location = new Point(0, 0x1e2);
            this.barDockControlBottom.Size = new Size(0x400, 0);
            this.barDockControlLeft.CausesValidation = false;
            this.barDockControlLeft.Dock = DockStyle.Left;
            this.barDockControlLeft.Location = new Point(0, 0);
            this.barDockControlLeft.Size = new Size(0, 0x1e2);
            this.barDockControlRight.CausesValidation = false;
            this.barDockControlRight.Dock = DockStyle.Right;
            this.barDockControlRight.Location = new Point(0x400, 0);
            this.barDockControlRight.Size = new Size(0, 0x1e2);
            this.barCheckItem1.Caption = "Xem trước khi in";
            this.barCheckItem1.Id = 4;
            this.barCheckItem1.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.barCheckItem1.ItemAppearance.Normal.Options.UseFont = true;
            this.barCheckItem1.Name = "barCheckItem1";
            this.barSubItem1.Caption = "barSubItem1";
            this.barSubItem1.Id = 5;
            this.barSubItem1.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(this.barEditItem1) });
            this.barSubItem1.Name = "barSubItem1";
            this.barEditItem1.Caption = "barEditItem1";
            this.barEditItem1.Edit = this.repositoryItemCheckEdit1;
            this.barEditItem1.Id = 6;
            this.barEditItem1.Name = "barEditItem1";
            this.repositoryItemCheckEdit1.AutoHeight = false;
            this.repositoryItemCheckEdit1.Name = "repositoryItemCheckEdit1";
            this.barEditItem2.Caption = "barEditItem2";
            this.barEditItem2.Edit = this.repositoryItemCheckEdit2;
            this.barEditItem2.Id = 7;
            this.barEditItem2.Name = "barEditItem2";
            this.repositoryItemCheckEdit2.AutoHeight = false;
            this.repositoryItemCheckEdit2.Name = "repositoryItemCheckEdit2";
            this.barEditItem3.Caption = "barEditItem3";
            this.barEditItem3.Edit = this.repositoryItemTextEdit1;
            this.barEditItem3.Id = 8;
            this.barEditItem3.Name = "barEditItem3";
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.barEditItem4.Caption = "barEditItem4";
            this.barEditItem4.Edit = this.repositoryItemTextEdit3;
            this.barEditItem4.Id = 9;
            this.barEditItem4.Name = "barEditItem4";
            this.repositoryItemTextEdit3.AutoHeight = false;
            this.repositoryItemTextEdit3.Name = "repositoryItemTextEdit3";
            this.barEditItem5.Caption = "barEditItem5";
            this.barEditItem5.Edit = this.repositoryItemTextEdit4;
            this.barEditItem5.Id = 10;
            this.barEditItem5.Name = "barEditItem5";
            this.repositoryItemTextEdit4.AutoHeight = false;
            this.repositoryItemTextEdit4.Name = "repositoryItemTextEdit4";
            this.barCheckItem2.Caption = "Thuốc kh\x00f4ng k\x00ea đơn";
            this.barCheckItem2.Id = 12;
            this.barCheckItem2.Name = "barCheckItem2";
            this.bbithuockhongkedon.Caption = " Thuốc kh\x00f4ng k\x00ea đơn";
            this.bbithuockhongkedon.Edit = this.repositoryItemCheckEdit4;
            this.bbithuockhongkedon.EditValue = false;
            this.bbithuockhongkedon.Glyph = Resources.Reso.imgclose;// (Image)manager.GetObject("bbithuockhongkedon.Glyph");
            this.bbithuockhongkedon.Id = 13;
            this.bbithuockhongkedon.ItemClickFireMode = BarItemEventFireMode.Postponed;
            this.bbithuockhongkedon.Name = "bbithuockhongkedon";
            this.bbithuockhongkedon.ItemClick += new ItemClickEventHandler(this.bbithuockhongkedon_ItemClick);
            this.repositoryItemCheckEdit4.AutoHeight = false;
            this.repositoryItemCheckEdit4.Name = "repositoryItemCheckEdit4";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            //base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.standaloneBarDockControl1);
            base.Controls.Add(this.groupControl2);
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.barDockControlLeft);
            base.Controls.Add(this.barDockControlRight);
            base.Controls.Add(this.barDockControlBottom);
            base.Controls.Add(this.barDockControlTop);
            base.Name = "ucd_xuatkho_banle_ll_khonghoadon";
            base.Size = new Size(0x400, 0x1e2);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.repositoryItemTextEdit2.EndInit();
            this.txtma.Properties.EndInit();
            this.txtten.Properties.EndInit();
            this.gridView1.EndInit();
            this.gridds.EndInit();
            this.txtsophieu.Properties.EndInit();
            this.txtmavach.Properties.EndInit();
            this.datengay.Properties.VistaTimeProperties.EndInit();
            this.datengay.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.cbbnhomkh.Properties.EndInit();
            this.txttongchietkhau.Properties.EndInit();
            this.txttongvat.Properties.EndInit();
            this.txttongtienthua.Properties.EndInit();
            this.txttongthucthu.Properties.EndInit();
            this.txttongthanhtoan.Properties.EndInit();
            this.txttongtien.Properties.EndInit();
            this.groupControl2.EndInit();
            this.groupControl2.ResumeLayout(false);
            this.cbbdonggoi.Properties.EndInit();
            this.txtsoluong.Properties.EndInit();
            this.barManager1.EndInit();
            this.repositoryItemCheckEdit3.EndInit();
            this.repositoryItemCheckEdit1.EndInit();
            this.repositoryItemCheckEdit2.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.repositoryItemTextEdit3.EndInit();
            this.repositoryItemTextEdit4.EndInit();
            this.repositoryItemCheckEdit4.EndInit();
            base.ResumeLayout(false);
        }

        private void nummiengiam_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void numthue_Enter(object sender, EventArgs e)
        {
        }

        private void tbnumslsang_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void txtma_Validated(object sender, EventArgs e)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("ma='" + this.txtma.Text + "'");
                this.f_SetControl_dmsanpham(long.Parse(rowArray[0]["id"].ToString()));
                if (rowArray.Length > 0)
                {
                    this.ctrdanhsach_vp.Visible = false;
                }
            }
            catch
            {
            }
        }

        private void txtmavach_Enter(object sender, EventArgs e)
        {
            try
            {
                this.txtmavach.SelectionStart = 0;
                this.txtmavach.SelectAll();
            }
            catch
            {
            }
        }

        private void txtten_Enter(object sender, EventArgs e)
        {
            this.ctrdanhsach_vp.Width = (this.txtten.Location.X + this.txtten.Width) - this.txtma.Location.X;
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = string.Concat(new object[] { this.txtten.Location.X - this.txtma.Location.X, ",", ((this.ctrdanhsach_vp.Width - 0x66) - this.txtten.Location.X) + this.txtma.Location.X, ",", 50, ",50" });
            this.ctrdanhsach_vp.Location = new Point(this.txtma.Location.X, (this.txtma.Location.Y + this.txtma.Height) + 1);
            this.ctrdanhsach_vp.BringToFront();
        }

        private void txtten_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))
            {
                if (this.ctrdanhsach_vp.Visible)
                {
                    this.ctrdanhsach_vp.Focus();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.ctrdanhsach_vp.Visible = false;
            }
            else
            {
                this.ctrdanhsach_vp.Visible = false;
                this.ucDMSanPham_KeyDown(sender, e);
            }
        }

        private void txtten_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.txtten.IsEditorActive)
                {
                    this.ctrdanhsach_vp.Visible = true;
                    this.ctrdanhsach_vp.Locdulieu(this.txtten.Text);
                }
            }
            catch
            {
            }
        }

        private void txtten_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void txttenhoatchat_Validated(object sender, EventArgs e)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("mavach='" + this.txtmavach.Text + "'");
                this.f_SetControl_dmsanpham(long.Parse(rowArray[0]["iddp"].ToString()));
                if (rowArray.Length > 0)
                {
                    this.ctrdanhsach_vp.Visible = false;
                }
            }
            catch
            {
            }
        }

        private void txttongthucthu_Click(object sender, EventArgs e)
        {
            try
            {
                this.txttongthucthu.SelectionStart = 0;
                this.txttongthucthu.SelectAll();
            }
            catch
            {
            }
        }

        private void txttongthucthu_EditValueChanged(object sender, EventArgs e)
        {
            if (this.txttongthucthu.IsEditorActive)
            {
                try
                {
                    this.txttongthucthu_Validated(null, null);
                }
                catch
                {
                }
            }
        }

        private void txttongthucthu_Enter(object sender, EventArgs e)
        {
            try
            {
                this.txttongthucthu.SelectionStart = 0;
                this.txttongthucthu.SelectAll();
            }
            catch
            {
            }
        }

        private void txttongthucthu_Validated(object sender, EventArgs e)
        {
            decimal num = 0M;
            try
            {
                num = Convert.ToDecimal(this.txttongthucthu.EditValue) - Convert.ToDecimal(this.txttongthanhtoan.EditValue);
            }
            catch
            {
            }
            if (num >= 0M)
            {
                this.lblthuathieu.Text = "Tiền thừa:";
            }
            else
            {
                this.lblthuathieu.Text = "Tiền thiếu:";
            }
            this.txttongtienthua.EditValue = Math.Abs(num);
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.F1)
            {
                if (this.btnthem.Enabled)
                {
                    this.btnmoi_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (this.bbiluu.Enabled)
                {
                    this.btnluu_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F4)
            {
                if (this.bbiboqua.Enabled)
                {
                    this.btnboqua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F11)
            {
                if (this.bbiinphieu.Enabled)
                {
                    this.btnin_Click(null, null);
                }
            }
            else if ((e.KeyCode == Keys.F12) && this.bbiketthuc.Enabled)
            {
                this.btnketthuc_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this.txtsophieu.Properties.ReadOnly = true;
            this._xuatban = new DXuatBanLe(this._xuli.pConFigData);
            this.f_load_nhomkh();
            if (this._dtobanle.pID == 0L)
            {
                this.btnmoi_Click_1(null, null);
            }
            else
            {
                this.f_Loaddata_dmvp();
                this.f_setcontrol_xuatbanle(this._dtobanle.pID);
                this.f_loaddata_xuatbanlect(this._dtobanle.pID);
                this.f_loadinfo_chidinhchitiet(0);
                this.btnsua_Click(null, null);
            }
        }
    }
}

